package com.fjec.market.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.common.protocol.JsonResult;
import com.fjec.common.util.DateUtil;
import com.fjec.market.entity.BizFavorite;
import com.fjec.market.service.IBizFavoriteService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 018.收藏商品表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-09-16
 */
@RestController
@RequestMapping("/")
public class BizFavoriteController {

    @Resource
    private IBizFavoriteService service;

    /**
     * 收藏
     *
     * @param skuId
     * @return
     */
    @PostMapping("/y/favorite/save")
    public JsonResult saveFavorite(Long skuId) {
        return service.saveFavorite(skuId);
    }

    /**
     * 取消收藏
     *
     * @param skuId
     * @return
     */
    @PostMapping("/y/favorite/delete")
    public JsonResult deleteFavorite(Long skuId) {
        return service.deleteBySkuId(skuId);
    }

    /**
     * 收藏列表
     *
     * @return
     */
    @GetMapping("/y/favorite/getFavoriteByUserId")
    public JsonResult getFavoriteByUserId(Page page) {
        return service.favoriteList(page);
    }
}
